﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using FCNS.Utility;

using FCNS.KeepMoneyLibrary.Util;

namespace FCNS.KeepMoney.Forms
{
    public partial class TextForm : ParentForm
    {
        UI.ListViewItemGtd gtdItem = null;

        public TextForm()
        {
            InitializeComponent();
            Program.Translation.ApplyTo(this);
        }

        public string GetText
        {
            get { return textBox1.Text.Trim(); }
        }

        public GtdColor GetColor
        {
            get { return (GtdColor)comboBoxColor.SelectedIndex; }
        }

        public void Init(string title, string describe,string text)
        {
            BannerFactory.CreateBannerEx(this, pictureBoxLogo, Properties.Resources.box1_32,
               title, describe);
            textBox1.Text = text;
        }

        public void UsedByGtd(UI.ListViewItemGtd gtdItem)
        {
            comboBoxColor.Visible = true;
            comboBoxColor.Items.AddRange(Enum.GetNames(typeof(GtdColor)));
            comboBoxColor.SelectedIndex = 0;

            if (gtdItem != null)
            {
                this.gtdItem = gtdItem;
                textBox1.Text = gtdItem.Text;
                comboBoxColor.SelectedIndex = (int)gtdItem.GroupField.Color;
            }
        }

        public void UsedByMutliTextEdit()
        {
            comboBoxColor.Visible = false;
            this.Height += 50;
            textBox1.Multiline = true;
            textBox1.Height += 50;
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (gtdItem != null)
            {
                gtdItem.Text = textBox1.Text.Trim();
                gtdItem.GroupField.Color = (GtdColor)comboBoxColor.SelectedIndex;
                gtdItem.Color = gtdItem.GroupField.ColorBorder;
            }
            this.DialogResult = DialogResult.OK;
        }
    }
}
